package jaxb.util;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;

import javax.xml.bind.annotation.adapters.XmlAdapter;

public class UUIDSetToArrayAdapter<T> extends XmlAdapter<UUID[], Set<UUID>> {
    
    @Override
    public Set<UUID> unmarshal(UUID[] v) throws Exception
    {
        HashSet<UUID> set = new HashSet<UUID>();
        set.addAll(Arrays.asList(v));
        return set;
    }
    
    @Override
    public UUID[] marshal(Set<UUID> v) throws Exception
    {
        UUID[] ar = new UUID[v.size()];
        return v.toArray(ar);
    }
}
